package org.vectrics.recruiter.job;

import java.util.HashSet;
import java.util.Set;

import org.vectrics.SystemException;
import org.vectrics.common.db.RecordObject;
import org.vectrics.skill.Skill;

/**
 * @author mmoore
 *
 */
public class JobSkillRating implements RecordObject { //extends SkillRating {
	public static int CONJUNCTION_ADDITIVE = 0;
	public static int CONJUNCTION_MAXIMUM = 1;

	private Long id = null;
	private Long additiveDecay = new Long(0);
	private JobSkillRating parent = null;
	private int childConjunctionType = CONJUNCTION_ADDITIVE;
	private Set childSkillRatings = new HashSet();
	private Skill skill = null;
	private Boolean viewChildren = new Boolean(true);
	private Integer level = new Integer(100);
	private String description = null;
	
	private Job job = null;
	
	
	public JobSkillRating() {
		super();
	}
	
	/**
	 * @return Returns the id.
	 */
	public Long getId() {
		return id;
	}
	/**
	 * @param id The id to set.
	 */
	public void setId(Long id) {
		this.id = id;
	}
	/**
	 * @return Returns the job.
	 */
	public Job getJob() {
		return job;
	}
	/**
	 * @param job The job to set.
	 */
	public void setJob(Job job) {
		this.job = job;
	}

	public boolean hasSkill() {
		return(true);
	}

	public int getChildConjunctionType() {
		return childConjunctionType;
	}

	public void setChildConjunctionType(int childConjunctionType) {
		this.childConjunctionType = childConjunctionType;
	}
	
	public JobSkillRating getParent() {
		return parent;
	}
	
	/**
	 * @param parent The parent to set.
	 */
	public void setParent(JobSkillRating parent) {
		this.parent = parent;
		//if (parent != null) {
		//	parent.childSkillRatings.add(this);
		//}
	}
	
	/**
	 * @return Returns the childSkillRatings.
	 */
	public Set getChildSkillRatings() {
		return childSkillRatings;
	}
	/**
	 * @param childSkillRatings The childSkillRatings to set.
	 */
	public void setChildSkillRatings(Set childSkillRatings) {
		this.childSkillRatings = childSkillRatings;
	}
	
	public JobSkillRating addChildRating(Skill skill, String description) {
		JobSkillRating childRating = new JobSkillRating();
		if (description == null)
			description = "Child " + this.childSkillRatings.size();
		if (job == null)
			throw new SystemException("Attempt to add a child rating element before job was assigned to parent");
		//childRating.setId(CoreServiceLocator.getSurrogateKeyService().getKey("job.skill.id"));
		childRating.setJob(this.job);
		childRating.setDescription(description);
		childRating.setSkill(skill);
		childRating.setParent(this);
		this.childSkillRatings.add(childRating);
		return(childRating);
	}
	
	
	
	/**
	 * @return Returns the level.
	 */
	public Integer getLevel() {
		return level;
	}
	/**
	 * @param level The level to set.
	 */
	public void setLevel(Integer level) {
		this.level = level;
	}
	/**
	 * @return Returns the skill.
	 */
	public Skill getSkill() {
		return skill;
	}
	/**
	 * @param skill The skill to set.
	 */
	public void setSkill(Skill skill) {
		this.skill = skill;
	}
	
	
	/**
	 * @return Returns the viewChildren.
	 */
	public Boolean getViewChildren() {
		return viewChildren;
	}
	/**
	 * @param viewChildren The viewChildren to set.
	 */
	public void setViewChildren(Boolean viewChildren) {
		this.viewChildren = viewChildren;
	}
	
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public Long getAdditiveDecay() {
		return additiveDecay;
	}

	public void setAdditiveDecay(Long additiveDecay) {
		this.additiveDecay = additiveDecay;
	}
}
